package plantshop.model.plants;
import java.io.Serializable;

import plantshop.model.Characteristics;
import plantshop.model.Location;

//import java.util.Random;


public abstract class Plant implements Serializable{
	private static final long serialVersionUID = -6249906401405806181L;
	
	public static final int ASTER_SEED_PRICE = 20;
	public static final int ASTER_SELL_PRICE = 50;
	public static final int ASTER_VALUE = 13;
	
	private String name;
	private int seedPrice, sellPrice;
	private int value;
	private Characteristics characteristics;
	private boolean grown;
	private boolean available;
	private Location topLeft;
	private long timePlanted;
	protected boolean invasive;
	private boolean takenOver;
	
	public Plant(String name, int seedPrice, int sellPrice, int value, Characteristics chars) {
		this.name = name;
		this.seedPrice = seedPrice;
		this.sellPrice = sellPrice;
		this.value = value;
		characteristics = chars;
		grown = false;
		available = true;
		topLeft = new Location(0,0);
		timePlanted = System.currentTimeMillis();
		takenOver = false;
	}
	
	public boolean getAvailable(){
		return available;
	}
	
	public void setLoc(int x, int y){
		topLeft.setX(x);
		topLeft.setY(y);
	}
	
	public Location getLoc(){
		return topLeft;
	}
	
	public void grow(){
		grown = true;
		takenOver = false;
	}
	public void markTaken(){
		markTaken(false);
	}
	public void markTaken(boolean available){
		this.available = available;
	}
	public boolean available(){
		return available;
	}
	
	public Characteristics getCharacteristics() {
		return characteristics;
	}
	public boolean isGrown() {
		return grown;
	}
	public String getName() {
		return name;
	}
	public int getSeedPrice() {
		return seedPrice;
	}
	public int getSellPrice() {
		return sellPrice;
	}
	public int getValue() {
		return value;
	}
	public long getTimePlanted() {
		return timePlanted;
	}
	public abstract int getAttractiveness();
	
	@Override
	public boolean equals(Object p) {
		if(p instanceof Plant)
		{
			if(((Plant)p).name == name)
				return true;
		}
		return false;
	}
	
	@Override
	public int hashCode() {
		return name.hashCode();
	}

	public boolean isInvasive() {
		return invasive;
	}
	
	public boolean getTakenOver()
	{
		return takenOver;
	}
	
	public void setTakenOver(boolean takenOver)
	{
		this.takenOver = takenOver;
	}

}
